import request from '@/utils/request/request';
import {
  APIAddParams,
  APIDetailInfo,
  APIListRes,
  APIParams,
  ExecuteAPI,
} from '@/api/infrastructure/model/apiModal';

// 分页查询API数据
export function queryAPIRecordListByPage(params: APIParams) {
  return request.get<APIListRes>('/api/infra/form-api/page', {
    params,
  });
}

// 新增API
export function addAPIRecord(data: APIAddParams) {
  return request.post('/api/infra/form-api', data);
}

// 修改API
export function updateAPIRecord(data: APIAddParams) {
  return request.put('/api/infra/form-api', data);
}

// 根据APIid查API详细信息
export function getAPIDetailInfoById(id: string) {
  return request.get<APIDetailInfo>(`/api/infra/form-api/${id}`);
}

// 执行API
export function executeAPI(path: string, data: ExecuteAPI) {
  return request.post(`/api/infra/form-api/custom/${path}`, data);
}

// 删除API
export function deleteAPIRecord(id: string) {
  return request.delete(`/api/infra/form-api/${id}`);
}
